from api import client
# from common.read_yaml import ReadYamlConfigs
from common.route import *
# from common.read_yaml import get_yaml_filepath
# from common.readconfig import Environ
from common.read_yaml import configs_data

data = configs_data

class ReceivingApi(client.HttpClient):
    def __init__(self,token):
        self.host = data['admin_host']
        self.token = token

    """-----------------------------------商城前台---------------------------------"""
    """添加收获地址"""
    data0 = add_shipping_address['case_data'][0]['body']
    def add_shipping_address(self,
            city= data0['city'],
            defaultStatus= data0['defaultStatus'],
            detailAddress= data0['detailAddress'],
            id= data0['id'],
            memberId= data0['memberId'],
            name= data0['name'],
            phoneNumber= data0['phoneNumber'],
            postCode= data0['postCode'],
            province= data0['province'],
            region= data0['region']
    ):
        body = {
            "city": city,
            "defaultStatus": 0,
            "detailAddress": detailAddress,
            "id": 0,
            "memberId": 0,
            "name": name,
            "phoneNumber": phoneNumber,
            "postCode": postCode,
            "province": province,
            "region": region
        }

        url =add_shipping_address['url']
        method = add_shipping_address['method']
        url = self.get_full_url(url)
        return self.send(url,body,method=method,x_token=self.token)
    "显示所有收货地址"
    data0 = address_list['case_data'][0]['body']
    def address_list(self):
        url = address_list['url']
        url = self.get_full_url(url)
        method = address_list['method']
        return self.send(url,method=method,x_token=self.token)

    "删除收货地址"
    data0 = address_delete['case_data'][0]['body']
    def address_delete(self,
                       id=data0['id']):
        method = address_delete['method']
        url = address_delete['url']
        url = self.get_full_url(url,replace=str(id))
        return self.send(url,method=method,x_token=self.token)
